

<template>
  <el-header style="text-align: right; font-size: 12px; display: flex; justify-content: space-between; align-items: center;">
    <div class="header-logo">
      <img src="@/assets/logo.png" alt="Logo" style="height: 50px;"/>
    </div>
    <div class="toolbar">
    </div>
  </el-header>
  <el-container class="layout-container-demo" style="height: 900px">
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu :default-openeds="['1', '3']">
          <el-sub-menu index="1">
            <template #title>
              <el-icon><message /></el-icon>信息管理
            </template>
            <el-menu-item-group>

              <el-menu-item index="1-1">
                <router-link :to="{path:'/myinfo'}">个人信息管理</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link :to="{path:'/alltheinfo'}">成员信息管理</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>


          <el-sub-menu index="2">
            <template #title>
              <el-icon><icon-menu /></el-icon>文章管理
            </template>
            <el-menu-item-group>

              <el-menu-item index="2-1">
                <router-link to="/articleClass">文章发布</router-link>
              </el-menu-item>

              <el-menu-item index="2-2">
                <router-link to="/searchArticle">文章查询</router-link>
              </el-menu-item>

<!--              <el-menu-item index="2-3">文章发布</el-menu-item>-->
            </el-menu-item-group>

          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon><setting /></el-icon>数据统计
            </template>
            <el-menu-item-group>

              <el-menu-item index="3-1">今日数据统计</el-menu-item>
              <el-menu-item index="3-2">历史数据统计</el-menu-item>
            </el-menu-item-group>


          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container>

      <el-header style="text-align: right; font-size: 12px">

        <div class="toolbar">
          <el-dropdown>
            <el-icon style="margin-right: 8px; margin-top: 1px">
              <setting />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>View</el-dropdown-item>
                <el-dropdown-item>Add</el-dropdown-item>
                <el-dropdown-item @click="goout">退出</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <span>{{ username }}</span>
        </div>
      </el-header>

      <el-main>

        <router-view></router-view>

      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import {onBeforeMount, ref} from 'vue'
import { Menu as IconMenu, Message, Setting } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import axios from "axios";
const router = useRouter()
const username = ref('')

onBeforeMount(()=>{

  axios.get("http://localhost:8090/getuserinfo").then((res) => {
    console.log(res)
    username.value=res.data
  })

})

const goout =async ()=>{
  router.push("/")
}
const item = {
  date: '2016-05-02',
  name: 'Tom',
  address: 'No. 189, Grove St, Los Angeles',
}
const tableData = ref(Array.from({ length: 20 }).fill(item))
</script>

<style scoped>
.layout-container-demo {
  height: 100vh; /* 设置容器高度为视口高度 */
  display: flex; /* 使用flex布局 */
}

.layout-container-demo .el-header {
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
  padding: 0 20px; /* 增加内边距 */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
}

.layout-container-demo .el-aside {
  background: var(--el-color-primary-light-8);
  width: 200px; /* 固定宽度 */
  min-width: 200px; /* 最小宽度 */
  max-width: 200px; /* 最大宽度 */
  transition: width 0.3s ease; /* 过渡效果 */
  padding: 15px; /* 内边距 */
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  overflow-y: auto; /* 添加滚动条 */
}

/* 响应式设计 */
@media (max-width: 768px) {
  .layout-container-demo .el-aside {
    width: 100%; /* 在小屏幕上占满整个宽度 */
    box-shadow: none; /* 移除阴影效果 */
  }
}

.layout-container-demo .el-menu {
  border-right: none;
  height: 100%; /* 菜单高度占满侧边栏 */
}

.layout-container-demo .el-container {
  flex: 1; /* 使容器占据剩余空间 */
  display: flex; /* 使用flex布局 */
  flex-direction: column; /* 子项目垂直排列 */
}

.layout-container-demo .el-main {
  flex: 1; /* 主内容区域占据剩余空间 */
  overflow-y: auto; /* 添加滚动条 */
  background-image: url('@/assets/img_4.png'); /* 设置背景图片 */
  background-repeat: no-repeat; /* 不重复显示 */
  background-position: center; /* 居中显示 */
  background-size: cover; /* 覆盖整个区域 */
}

.layout-container-demo .toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* 调整为右对齐 */
  height: 100%;
  padding-right: 20px; /* 增加右边距 */
}


.layout-container-demo .el-header {
  background-color: var(--el-color-primary-light-7); /* 设置背景颜色 */
  color: var(--el-text-color-primary);
  padding: 0 20px; /* 增加内边距 */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
  display: flex;
  justify-content: space-between; /* 元素之间的间距 */
  align-items: center; /* 垂直居中 */
  background-image: url('@/assets/logo.png'); /* 设置背景图片 */
  background-repeat: repeat; /* 平铺显示 */
  background-position: center; /* 背景图片居中显示 */
}

/* 仅对头部左侧区域应用背景图片 */
.layout-container-demo .el-header .header-logo {
  background-image: url('@/assets/logo.png');
  background-repeat: repeat;
  background-position: center;
  background-size: cover;
}

/* 设置头部右侧区域（用户名和设置）的样式 */
.layout-container-demo .el-header .toolbar {
  background-color: var(--el-color-primary-light-7); /* 与头部背景颜色一致 */
  padding: 0px; /* 增加内边距 */
  border-radius: 5px; /* 增加边框圆角 */
}

/* ...其他样式... */

.header-logo img {
  height: 50px; /* 设置图片高度 */
  margin-right: auto; /* 将图片推向左边 */
}


</style>